﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;

using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using Hopthoai;

namespace QUANLYCHAMCONG
{
    public partial class Frmdangkymaychamcong : Form
    {
        public Frmdangkymaychamcong()
        {
            InitializeComponent();
        }

        private void simpleButton3_Click(object sender, EventArgs e)
        {
            Application.ExitThread();
            Application.Exit();
        }
        string strPath = "Software\\Settings";
        string strWindowsState = "";
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(txtmadangky.Text))
            {
                try
                {


                    //lam ri do o day
                    if (txtmadangky.Text == "hangocthanh3107@gmail.com")
                    {
                        RegistryKey regKeyAppRoot = Registry.CurrentUser.CreateSubKey(strPath);
                        regKeyAppRoot.SetValue("WindowState", "-1");
                        frmHoidap f = new frmHoidap("Đăng ký thành công!", frmHoidap.CO.an, frmHoidap.KHONG.an, frmHoidap.THOAT.an, frmHoidap.HINH.thongtin);
                        f.ShowDialog();
                    }
                    else
                    {
                        RegistryKey regKeyAppRoot = Registry.CurrentUser.CreateSubKey(strPath);
                        strWindowsState = (string)regKeyAppRoot.GetValue("WindowState");
                        //write lai
                        int solan = int.Parse(strWindowsState.ToString()) - 1;
                        RegistryKey regwrite = Registry.CurrentUser.CreateSubKey(strPath);
                        regwrite.SetValue("WindowState", solan.ToString());
                        frmHoidap f = new frmHoidap("Đăng ký thất bại!", frmHoidap.CO.an, frmHoidap.KHONG.an, frmHoidap.THOAT.an, frmHoidap.HINH.baoloi);
                        f.ShowDialog();
                    }
                    Application.ExitThread();
                    Application.Exit();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
        }
    }
}
